package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.domain.DeviceData;
import com.zzyl.nursing.domain.FamilyMemberEder;
import com.zzyl.nursing.dto.DeviceDataDto;
import com.zzyl.nursing.dto.DeviceDto;
import com.zzyl.nursing.dto.FamilyMemberDto;
import com.zzyl.nursing.dto.DeviceDataDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.DeviceDataVoo;
import com.zzyl.nursing.vo.FamilyMemberVO;
import com.zzyl.nursing.vo.DeviceDataVoo;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.health.HealthDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 *
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;
    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }
    @PostMapping("/add")
    @ApiOperation("添加家人")
    public AjaxResult add(@RequestBody FamilyMemberDto dto){
        int i = familyMemberService.add(dto);
        return i>0?success():error();
    }

    @GetMapping("my")
    @ApiOperation("查询家人列表")
    public AjaxResult my(){
        List<FamilyMemberEder> list = familyMemberService.my();

        return AjaxResult.success(list);
    }
    @GetMapping("/list-by-page")
    @ApiOperation("分页查询")
    public R<List<FamilyMemberVO>> listByPage(){
        startPage();

        return R.ok( familyMemberService.listByPage());

    }
    @PostMapping("/QueryDevicePropertyStatus")
    @ApiOperation("查询健康数据")
    public R<HealthDataVo> QueryDevicePropertyStatus(@RequestBody DeviceDto dto){
        startPage();

        return R.ok( familyMemberService.QueryDevicePropertyStatus(dto));

    }
    @DeleteMapping("deleteById")
    @ApiOperation("解绑老人")
    public R<Integer> deleteById(Long id){
        return R.ok( familyMemberService.deleteFamilyMemberElderById(id));

    }
    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public R<List<DeviceDataVoo>> queryDeviceDataListByDay(DeviceDataDto dto){
        return R.ok(familyMemberService.queryDeviceDataListByDay(dto));
    }

    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public R<List<DeviceDataVoo>> queryDeviceDataListByWeek( DeviceDataDto dto){
        return R.ok(familyMemberService.queryDeviceDataListByWeek(dto));
    }




}
